﻿using CloudMusic.Model;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace CloudMusic.Converters
{
    /// <summary>
    /// 播放模式转化
    /// </summary>
    public class PlayModeToStreamGeometryConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            string iconKey = string.Empty;
            switch ((PlayModelState)value)
            {
                case PlayModelState.Order:
                    iconKey = "Icon_Mode_Order";
                    break;
                case PlayModelState.RepeatAll:
                    iconKey = "Icon_Mode_Lsit";
                    break;
                case PlayModelState.RepeatOne:
                    iconKey = "Icon_Mode_Single";
                    break;
                case PlayModelState.Random:
                    iconKey = "Icon_Mode_Random";
                    break;
            }

            if (iconKey != string.Empty && App.Current.FindResource(iconKey) is StreamGeometry sg)
                return sg;
            else
                return Binding.DoNothing;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value != null && value.Equals(true) ? parameter : Binding.DoNothing;
        }
    }
}
